<?php
/*
 * [JINYUN!] (C)2001-2099 Jinyunweb.com
 * This is NOT a freeware, use is subject to license terms
 * $Id: 2017-12-13 03:39:35 apple $
*/
/*
	选择会员
*/
defined('BY_JYA') or exit('error');
$_RQ['op']=$_RQ['op']?$_RQ['op']:'one';
$return=array();
	//会员列表
	$pindex = max(1, intval($_RQ['page']));
	$psize = 10;
	$return['params']=$params=array('uniacid'=>$_SESSION['uniacid'],'is_agent'=>'1');
	$parameter=array(
		'params'=>$params,
		'limit'=>array($pindex,$psize),
		'orderby'=>'agenttime desc',
		
	);
	$list=$this->get_list('member',$parameter,$total);
	if($list){
		foreach($list as &$item){
			$item['member']=cfc('core')->member_show($item['mid']);
			//整理返回数据
			if($_RQ['op']=='many'){
				$item['res']=array('mid'=>$item['id'],'title'=>$item['member']['nickname'],'image'=>$item['member']['avatar']);
			}else{
				$item['res']=$item['mid'];
			}
		}
	}
	$return['list']=$list;
	$totalpage=ceil($total/$psize);
	$totalpage=intval($totalpage);
	$return['totalpage'] =$totalpage;
	$return['params']['page'] =$pindex;
	$return['htmls']=array(
		'type'=>'list',
		'list'=>array('data'=>'list','del_one'=>false,'delall'=>false,'edit'=>false,'list'=>array(
		    array('name'=>'mid','title'=>'会员id','type'=>'string'),
			array('name'=>'member','title'=>'经销商','type'=>'member'),
			array('name'=>'level_id','title'=>'经销商等级','type'=>'select','options'=>'levels'),
			array('name'=>'agenttime','title'=>'成为经销商时间','type'=>'time'),
		),'action'=>array(
			array('type'=>'modal_result','name'=>'res','title_field'=>'nickname','title'=>'选取'),
		)),
	);
	$return['levels']=$this->getall('level',array('uniacid'=>$_SESSION['uniacid']),array('id','title'),'id');
	exi($return);
